 package net.go176.backpack.util;
 
 import org.bukkit.Material;
 import org.bukkit.entity.HumanEntity;
 import org.bukkit.inventory.Inventory;
 import org.bukkit.inventory.ItemStack;
 
 
 public class InvTrans
 {
   public static boolean legacy = true;
   
   public static int fromPlayerToMyb(int i) {
     if (i >= 0 && i < 9)
       return i + 36; 
     if (i >= 36 && i <= 39)
       return 39 - i; 
     if (!legacy && i == 40)
       return 8; 
     return i;
   }
   
   public static boolean canMybToPlayer(int i) {
     return !((i < 9 || i >= 45) && (i < 0 || i > 3) && (legacy || i != 8));
   }
   
   public static int fromMybToPlayer(int i) {
    if (i >= 36 && i < 45)
       return i - 36; 
     if (i >= 0 && i <= 3)
       return 39 - i; 
     if (!legacy && i == 8)
       return 40; 
     return i;
   }
   
   public static boolean canNBTToMyb(int i) {
     return !((i < 0 || i >= 36) && (i < 100 || i > 103) && (legacy || i != 150));
   }
   
   public static int fromNBTToMyb(int i) {
     if (i >= 0 && i < 9)
       return i + 36; 
     if (i >= 100 && i <= 103)
       return 103 - i; 
     if (!legacy && i == 150)
       return 8; 
     return i;
   }
   
   public static boolean canMybToNBT(int i) {
     return !((i < 9 || i >= 45) && (i < 0 || i > 3) && i != 8);
   }
   
   public static int fromMybToNBT(int i) {
     if (i >= 36 && i < 45)
       return i - 36; 
     if (i >= 0 && i <= 3)
       return 103 - i; 
     if (i == 8)
       return 150; 
     return i;
   }
   
   public static void readInventory(Inventory inv, Inventory source) {
     if (source instanceof org.bukkit.inventory.PlayerInventory) {
       for (int i = 0; i < (legacy ? 40 : 41); i++) {
         int j = fromPlayerToMyb(i);
         if (j >= 0 && j < inv.getSize()) {
           inv.setItem(j, source.getItem(i));
         }
       } 
     } else {
       for (int i = 0; i < inv.getSize(); i++)
         inv.setItem(i, source.getItem(i)); 
     } 
   }
   public static void writeInventory(Inventory inv, Inventory source) {
     if (source instanceof org.bukkit.inventory.PlayerInventory) {
       for (int i = 0; i < inv.getSize(); i++) {
         if (canMybToPlayer(i)) {
           source.setItem(fromMybToPlayer(i), inv.getItem(i));
         }
       } 
     } else {
       for (int i = 0; i < inv.getSize(); i++)
         source.setItem(i, inv.getItem(i)); 
     } 
   }
   public static void popUpItem(HumanEntity viewer, ItemStack item) {
     ItemStack itemCursor = viewer.getItemOnCursor();
     if (itemCursor.getType() != Material.AIR)
       viewer.getWorld().dropItem(viewer.getLocation(), itemCursor); 
     viewer.setItemOnCursor(item);
   }
 }


/* Location:              D:\User\Xuan\Downloads\MyBackpack1.2.5.jar!\net\saralab\mybackpac\\util\InvTrans.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.1.3
 */